package com.lemon.components.ant.project.makers;

import com.lemon.components.ant.project.beans.ServiceInfo;
import com.lemon.components.ant.util.TemplateUtil;
import com.lemon.components.docs.mysql.MysqlLocalTool;
import com.system.core.security.NameUtil;

public class ServiceDTOMaker {

	public void makeServiceDTO(ServiceInfo serviceInfo) {
		serviceInfo.setColumns(MysqlLocalTool.getColumnInfo(serviceInfo.getProjectInfo(), NameUtil.javaName2_(serviceInfo.getModelName())));
		
		TemplateUtil.getInstance(serviceInfo.getProjectInfo().getTemplatePath()).build(
				"/maven-project-template/service/QueryFilter.java", 
				serviceInfo.getServicesrcPath()+serviceInfo.getServiceClazzPath()+"/dto/"+NameUtil.getClassName(serviceInfo.getServiceName())+"QueryFilter.java",
				serviceInfo);

		serviceInfo.setServiceOpt("Add");
		TemplateUtil.getInstance(serviceInfo.getProjectInfo().getTemplatePath()).build(
				"/maven-project-template/service/ServiceOptBeanTemplate.java", 
				serviceInfo.getServicesrcPath()+serviceInfo.getServiceClazzPath()+"/dto/"+NameUtil.getClassName(serviceInfo.getServiceName())+"AddReq.java", 
				serviceInfo);
		
		serviceInfo.setServiceOpt("Update");
		TemplateUtil.getInstance(serviceInfo.getProjectInfo().getTemplatePath()).build(
				"/maven-project-template/service/ServiceOptBeanTemplate.java", 
				serviceInfo.getServicesrcPath()+serviceInfo.getServiceClazzPath()+"/dto/"+NameUtil.getClassName(serviceInfo.getServiceName())+"UpdateReq.java", 
				serviceInfo);
	}
}
